package edu.zju.udms.dnavigator.core.entity;

import java.util.ArrayList;
import java.util.List;

import edu.zju.udms.dnavigator.core.repository.Repository;

public abstract class Entity extends MetaObject implements Analyzable{	
	
	private static final long serialVersionUID = 787745387751026685L;
	
	@AttributeType(AttributeTypeEnum.Key)
	private String name;
	
	@AttributeType(AttributeTypeEnum.Key)
	private String qualifiedName;
	
	@AttributeType(AttributeTypeEnum.Key)
	private GeneralType type;
	
	@AttributeType(AttributeTypeEnum.Key)
	private String source;
	
	@AttributeType(AttributeTypeEnum.Version)
	private long createTime;
	
	@AttributeType(AttributeTypeEnum.Version)
	private long updateTime;
	
	@AttributeType(AttributeTypeEnum.Version)
	private String owner;
	
	@AttributeType(AttributeTypeEnum.Normal)
	private String bussinessName;
	
	@AttributeType(AttributeTypeEnum.Normal)
	private String description;
	
	public Entity(){}

	public Entity(String name, String qualifiedName, GeneralType type,
			String source, long createTime,long updateTime, String owner,
			String bussinessName,String description) {
		super();
		this.name = name;
		this.qualifiedName = qualifiedName;
		this.type = type;
		this.source = source;
		this.createTime = createTime;
		this.updateTime = updateTime;
		this.owner = owner;
		this.bussinessName = bussinessName;
		this.description = description;
	}


	@Override
	public List<Relation> analyze(Repository repository) {
		List<Relation> result = new ArrayList<>();
		List<Relation> temp = basicAnalyze(repository);
		if(temp!=null)
			result.addAll(temp);
		temp = advancedAnalyze(repository);
		if(temp != null)
			result.addAll(temp);
		return result;
	}
	
	/**
	 * This method is used to implement basic entity analysis.
	 * @param repository repository is used to access related entities
	 * @return relation set through the analysis 
	 * */
	private List<Relation> basicAnalyze(Repository repository) {
		return null;
	}
	
	/**
	 * This method is used to implement customized analysis.
	 * @param repository repository is used to access related entities
	 * @return relation set through the analysis 
	 * */
	protected List<Relation> advancedAnalyze(Repository repository){
		return null;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getQualifiedName() {
		return qualifiedName;
	}

	public void setQualifiedName(String qualifiedName) {
		this.qualifiedName = qualifiedName;
	}

	public GeneralType getType() {
		return type;
	}

	public void setType(GeneralType type) {
		this.type = type;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public long getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(long updateTime) {
		this.updateTime = updateTime;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public String getBussinessName() {
		return bussinessName;
	}

	public void setBussinessName(String bussinessName) {
		this.bussinessName = bussinessName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
}
